package collectionexercise;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("aaa");
        c.add("bbb");
        c.add(
                "ccc"
        );
        c.add("ddd");
        c.add("fff");
        System.out.println(c);
        Iterator<String> it = c.iterator();
        while (it.hasNext()){
            String str = it.next();
            if("ccc".equals(str)){
                it.remove();
            }
            System.out.println(str);
        }
        System.out.println(c);
     }
}
